package com.group8.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.group8.ge.Map;


public class PauseMenu extends Menu{
	
	private JPanel pausePanel;
	private int score;
	private Map plate[];
	
	JLabel mLabel;
	JLabel fxL;
	JLabel title;
	JLabel message;
	
	JCheckBox music;
	JCheckBox fxS;
	JButton back;
	
	public PauseMenu(){
		setPreferredSize(new Dimension(800,660));
		setLayout(null);
		setBackground(Color.black);
		
		CheckBoxListener cl = new CheckBoxListener();
		
		back = new JButton();
		Image img = new ImageIcon("assets/main_menu/back.png").getImage();
		back.setIcon(new ImageIcon(img));
		back.setRolloverEnabled(false);
		back.setBounds(500,500,93,40);
		back.addActionListener(cl);
		
		title = new JLabel("PAUSED");
		title.setBounds(270,90,300,100);
		title .setForeground(Color.GREEN);
		title.setFont(new Font("nfont", Font.PLAIN, 70));
		
		mLabel = new JLabel("Music");
		mLabel.setFont(new Font("nfont", Font.PLAIN, 40));
		mLabel.setForeground(Color.YELLOW);
		mLabel.setBounds(290,220,300,100);
		
		fxL = new JLabel("FX Sound");
		fxL.setFont(new Font("nfont", Font.PLAIN, 40));
		fxL.setBounds(280,310,300,100);
		fxL.setForeground(Color.DARK_GRAY);
		
		message = new JLabel("Press ESC to return to game");
		message.setFont(new Font("nfont", Font.PLAIN, 40));
		message.setForeground(Color.ORANGE);
		message.setBounds(140,380,600,200);
		
		
		music = new JCheckBox();
		music.setBounds(460,265,20,20);
		music.addActionListener(cl);
		
		fxS = new JCheckBox();
		fxS.setBounds(460,355,20,20);
		fxS.addActionListener(cl);
		
		add(music);
		add(fxS);
		add(mLabel);
		add(fxL);
		add(title);
		add(message);
		
	}
	
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);	
		Image bckgrnd = new ImageIcon("assets/gamePanelBackground.jpg").getImage();
		g.drawImage(bckgrnd, 0, 0, null);
	}
	
private class CheckBoxListener extends MenuActionListener{
		
		public void actionPerformed(ActionEvent e) {
			boolean sound = true, fx = true;
			if(e.getSource() == music)
				if(music.isSelected())
					sound = true;
				else
					sound = false;
			else if(e.getSource() == fxS)
				if(fxS.isSelected())
					fx = true;
				else
					fx = false;
			if(e.getSource() == back){
				switchPanels(getMain());
				System.out.println("Back clicked");
			}
			else
				changeSoundState(sound,fx);
			
		}
		
	}
	
	//TODO
	public void saveState() {
		
	}
	
	public void loadState() {
		
	}
}
